<?php
class InfoAction extends CommonAction{
	/*
	public function Index(){
		$Info=M('Info');
		import('ORG.Util.Page');// 导入分页类
		//$count= $User->where('status=1')->count();// 查询满足要求的总记录数
		$count= $Info->count();// 查询满足要求的总记录数
		$Page = new Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数
		$show = $Page->show();// 分页显示输出
// 进行分页数据查询 注意limit方法的参数要使用Page类的属性
$list = $Info->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);// 赋值数据集
$this->assign('page',$show);// 赋值分页输出	
		echo M()->getLastSql();
		$this->display();
	}
	*/
	public function Add(){
		$tempid= str_pad (time(), 12, 0, STR_PAD_RIGHT )+1;		
		$infoid=M("info");
		if ($infoid->where('infoid=$tempid')->find()){
			$tempid = $tempid+1;
		}
		else{
			$tempid = $tempid;
		}
		$this->assign('infoid',$tempid);		
		
		$this->display();
	}
	public  function insert(){
		$model = D ('Info');
		$model->create();
		dump($model);
		if (false === $model->create ()) {
			$this->error ( $model->getError () );
		}
		
		$model->mdzhaopian = $_POST['attachment_fileName'];//经营门店照片
		$model->grzhaopian = $_POST['fz_fileName'];//负责人照片
		$model->jyfanshi = implode(",",($_POST['jyfanshi']));//经营方式
		$model->fanwei = implode(",", ($_POST['fanwei']));//经营范围		
		$model->zdfenlei1 = implode(",", ($_POST['zdfenlei1']));//重点 监管 商品 1级分类
		
		$model->zdfenlei3 = implode(",", ($_POST['zdfenlei3']));//重点 监管 商品 3级分类
		$model->anquanshifan = implode(",", ($_POST['anquanshifan']));//食品安全示范店
		$model->jgrenyuanpic = $_POST['jg_fileName'];//监管人员照片
		$model->lrshiqi = date("Y-m-d H:i:s"); //录入时间		
		$list=$model->add ();
		
		//echo D()->getLastSql();
		
		if ($list!==false){
		//$this->ajaxReturn($list,"新增成功！",200);
     echo '{"statusCode":"200", 
      "message":"添加成功",
      "navTabId":"info_1",
      "rel":"info_1",
      "callbackType":"forward",
      "forwardUrl":""}';
		}
		else {
		echo '"statusCode":"300", 
      "message":"添加失败，请检查或联系管理员", 
      "navTabId":"info_1", 
      "rel":"info_1", 
      "callbackType":"forward",
      "forwardUrl":""';
		}
	}
	
	function search(){
		$this->display();
	}
	
}
?>